import React, { Component } from 'react';
import Item from '../Item';
import PubSub from 'pubsub-js';

export default class Content extends Component {
  render() {
    return (
      <div>
        {this.props.users.map(item => {
          return <Item key={item.id} nickname={item.login} imgSrc={item.avatar_url} />;
        })}
      </div>
    );
  }
  componentDidMount() {
    this.eventToken = PubSub.subscribe('myEvent', (msg, data) => {
      console.log('订阅收到消息：\n', msg, data);
    });
  }
  componentWillUnmount() {
    PubSub.unsubscribe(this.eventToken);
  }
}
